package com.wy.panda.constant;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.wy.panda.common.property.annotation.ConvertMethod;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 账户类型
 * 
 * @author wangyuan
 * @since 2020-9-12 10:41:18
 *
 */
@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public enum UserTypeEnum {
    
    SYSTEM_ADMIN(0, "系统管理员");
    
    @EnumValue
    @JsonValue
    private final Integer code;
    
    private final String name;
    
    @ConvertMethod
    public static UserTypeEnum getByCode(Integer code) {
        if(null == code) {
            return null;
        }
        
        UserTypeEnum result = null;
        for(UserTypeEnum item : values()) {
            if(item.getCode().equals(code)) {
                result = item;
                break;
            }
        }
        
        return result;
    }

    @Override
    public String toString() {
        return String.valueOf(getCode());
    }
}
